package com.dody.agile.payment.transaction;

import com.dody.agile.payment.classification.HourlyClassification;
import com.dody.agile.payment.employee.Employee;
import com.dody.agile.payment.model.TimeCard;

import java.util.Date;

/**
 * @author ShiXin
 * @date 2019/4/11 20:22
 * @description agile
 */
public class TimeCardTransaction extends PayrollTransaction{

    private int empId;
    private Date date;
    private double hours;


    public TimeCardTransaction(Date date, double hours, int empId) {
        this.empId = empId;
        this.date = date;
        this.hours = hours;
    }


    @Override
    public void execute() {

        Employee e = payrollDatabase.getEmployee(empId);
        if (null != e) {
            HourlyClassification hc = (HourlyClassification)e.getClassification();
            hc.addTimeCard(new TimeCard(date,hours));
        }


    }
}
